package com.gqyin.jpa.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.Index;
import jakarta.persistence.Table;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author guiqing.yin
 * @Date 2024-04-30 10:51
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(indexes = {
        @Index(name = "uk_username", columnList = "username", unique = true)
})
public class User extends BaseEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = -6676560997886790425L;

    private String username;

    private String password;

    @Size(min = 1, max = 16)
    private String nickname;

    @Email
    private String email;

    private UserStatus status;

    private LocalDateTime registerDate;

    private LocalDateTime lastLoginDate;
}
